home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8412.arc
/
BENCH.MOD
< prev
next >
Wrap
Text File
|
1986-09-14
|
3KB
|
156 lines
MODULE Benchmark;
(* This benchmark program (with minor changes)
is from "The Personal Computer Lilith," by N. Wirth,
Institute fur Informatik, ETH Zurich, 1981. *)
FROM Storage IMPORT ALLOCATE;
FROM Terminal IMPORT Read, Write, WriteLn;
TYPE
NodePtr = POINTER TO Node;
Node = RECORD
x, y : CARDINAL;
next : NodePtr;
END;
VAR
a, b, c : ARRAY [0..255] OF CARDINAL;
M : ARRAY [0..99], [0..99] OF CARDINAL;
m : CARDINAL;
head : NodePtr;
PROCEDURE Test(ch : CHAR);
VAR
i, j, k : CARDINAL;
p : NodePtr;
PROCEDURE P;
BEGIN
END P;
PROCEDURE Q(x, y, z, w : CARDINAL);
BEGIN
END Q;
BEGIN
CASE ch OF
(*----- Loops -----*)
'a' : (* Empty REPEAT loop *)
k := 20000;
REPEAT
k := k - 1;
UNTIL k = 0 |
'b' : (* Empty WHILE loop *)
i := 20000;
WHILE i > 0 DO
i := i - 1;
END |
'c' : (* Empty FOR loop *)
FOR i := 1 TO 20000 DO
END |
(*----- Cardinal Arithmetic -----*)
'd' : (* CARDINAL arithmetic *)
j := 0;
k := 10000;
REPEAT
k := k - 1;
j := j + 1;
i := (k * 3) DIV (j * 5);
UNTIL k = 0 |
(*----- Array Indexing -----*)
'e' : (* Array of single dimension *)
k := 20000;
i := 0;
b[0] := 73;
REPEAT
a[i] := b[i];
b[i] := a[i];
k := k - 1;
UNTIL k = 0 |
'f' : (* Two-dimensional array *)
FOR i := 0 TO 99 DO
FOR j := 0 TO 99 DO
M[i, j] := M[j, i];
END;
END |
(*----- Procedure Calls -----*)
'g' : (* Call of empty, parameterless procedure *)
k := 20000;
REPEAT
P;
k := k - 1;
UNTIL k = 0 |
'h' : (* Call of empty procedure with four parameters *)
k := 20000;
REPEAT
Q(i, j, k, m);
k := k - 1;
UNTIL k = 0 |
(*----- Block Move -----*)
'i' : (* Copying arrays (block moves) *)
k := 500;
REPEAT
k := k - 1;
a := b;
b := c;
c := a;
UNTIL k = 0 |
'j' : (* Pointer chaining *)
k := 500;
REPEAT
p := head;
REPEAT
p := p^.next;
UNTIL p = NIL;
k := k - 1;
UNTIL k = 0
END;
END Test;
VAR
ch : CHAR;
n : CARDINAL;
q : NodePtr;
BEGIN (* of MODULE Benchmark *)
head := NIL;
n := 100;
REPEAT (* initialize list *)
q := head;
NEW(head);
head^.next := q;
n := n - 1;
UNTIL n = 0;
Write('>');
Read(ch);
WHILE ('a' <= ch) & (ch <= 'j') DO
Write(ch);
WriteLn;
n := 0;
REPEAT
n := n + 1;
Test(ch); (* call the test routine *)
IF (n MOD 50) = 0 THEN
WriteLn;
END;
Write('.');
UNTIL n = 100;
WriteLn;
Write('>');
Read(ch);
END;
END Benchmark.